{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Think Bayes solutions: Chapter 4\n",
    "\n",
    "This notebook presents solutions to exercises in Think Bayes.\n",
    "\n",
    "Copyright 2016 Allen B. Downey\n",
    "\n",
    "MIT License: https://opensource.org/licenses/MIT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from __future__ import print_function, division\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "import thinkbayes2\n",
    "from thinkbayes2 import Pmf, Cdf, Suite\n",
    "import thinkplot\n",
    "\n",
    "% matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Euro problem\n",
    "\n",
    "Here's a class that represents hypotheses about the probability a coin lands heads."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class Euro(Suite):\n",
    "\n",
    "    def Likelihood(self, data, hypo):\n",
    "        \"\"\"Computes the likelihood of `data` given `hypo`.\n",
    "        \n",
    "        data: string 'H' or 'T'\n",
    "        hypo: probability of heads, 0-100\n",
    "        \n",
    "        returns: float\n",
    "        \"\"\"\n",
    "        x = hypo\n",
    "        if data == 'H':\n",
    "            return x/100\n",
    "        else:\n",
    "            return 1 - x/100"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can make a uniform prior and update it with 140 heads and 110 tails:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "suite = Euro(range(0, 101))\n",
    "dataset = 'H' * 140 + 'T' * 110\n",
    "\n",
    "for data in dataset:\n",
    "    suite.Update(data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And here's what the posterior looks like."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
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Figure at 0x7fe71d597d90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "thinkplot.Pdf(suite)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can summarize the posterior several ways, including the mean:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "55.952380952380956"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "suite.Mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Median:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "56"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "suite.Percentile(50)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The peak of the posterior, known as the Maximum Aposteori Probability (MAP)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "56"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "suite.MAP()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And a 90% credible interval"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(51, 61)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "suite.CredibleInterval(90)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can look up a particular value in the posterior PMF, but the result doesn't mean much, because we could have divided the range (0-100) into as many pieces as we like, and the result would be different."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.02097652612954468"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "suite.Prob(50)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Different priors\n",
    "\n",
    "Let's see how that looks with different priors.\n",
    "\n",
    "Here's a function that makes a uniform prior:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def UniformPrior(label='uniform'):\n",
    "    \"\"\"Makes a Suite with a uniform prior.\"\"\"\n",
    "    suite = Euro(range(0, 101), label=label)\n",
    "    return suite"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And another that makes a triangular prior."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def TrianglePrior(label='triangle'):\n",
    "    \"\"\"Makes a Suite with a triangle prior.\"\"\"\n",
    "    suite = Euro(label=label)\n",
    "    for x in range(0, 51):\n",
    "        suite[x] = x\n",
    "    for x in range(51, 101):\n",
    "        suite[x] = 100-x \n",
    "    suite.Normalize()\n",
    "    return suite"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's what they look like:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZYAAAEPCAYAAABhkeIdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VOX59/HPFcK+CagBBYMCimD7Q7FAFSyIKKtUKj4K\nuFZE0Ypt9RH7CAhoW6u1iAiIghZ3rVZWERSpoq0Lwk8NLgRtiGCAFlRkh1zPHzMMIU6SSZh9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/Ax539wPP+GwMjsGGmTUFYht6nRzOBM43sy+Ap4GzzexxoCgD98VXQKG7vx+cfoFAocnEn4tz\ngC/cfYu77wf+DpxBZu6LA8r67uuBFiXaRfT7NB0LS+ihTDOrQeDByrkJ7lO8zQJWu/v9JeYdeKgU\nynmoNJ24++/c/Th3P4HAz8FSd78UmEfm7YuNQKGZnRic1RPIIwN/LgicAutiZrWCF6J7Eri5I5P2\nhXHoUXxZ330ucHHwrrnjgdbAuxWuPB2fYzGz3gTugDnwYOUfE9yluDGzM4E3gI84ODzD7wj8MDxH\n4K+PAuAid/8mUf2MNzP7GfBbdz/fzBqTgfvCzP6HwE0M1YEvCDyMXI3M3BfjCPyxsRdYCVwN1CcD\n9oWZPQV0B5oAG4FxwEvA84T57mZ2G/BLAvtqlLsvrnAb6VhYREQkcdLxVJiIiCSQCouIiESVCouI\niESVCouIiESVCouIiESVCouIiESVCouIiESVCouIiESVCotIHJnZ6Wb2v8EhMuoGw6baJbpfItGk\nJ+9F4szMJhDIAKlNYGDIuxPcJZGoUmERiTMzq05gsNSdwBmuf4SSZnQqTCT+jgTqERj0sFaC+yIS\ndTpiEYkzM5tDIB/meOAYd/9VgrskElXZie6ASCYxs0uBPe7+jJllAW+ZWXd3X5bgrolEjY5YREQk\nqnSNRUREokqFRUREokqFRUREokqFRUREokqFRUREokqFRUREokqFRUREokqFRUREour/A7uF1OzV\ngfmaAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fe6ec6df490>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "triangle = TrianglePrior()\n",
    "uniform = UniformPrior()\n",
    "suites = [triangle, uniform]\n",
    "\n",
    "thinkplot.Pdfs(suites)\n",
    "thinkplot.Config(xlabel='x', ylabel='Probability')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we update them both with the same data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def RunUpdate(suite, heads=140, tails=110):\n",
    "    \"\"\"Updates the Suite with the given number of heads and tails.\n",
    "\n",
    "    suite: Suite object\n",
    "    heads: int\n",
    "    tails: int\n",
    "    \"\"\"\n",
    "    dataset = 'H' * heads + 'T' * tails\n",
    "    for data in dataset:\n",
    "        suite.Update(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "for suite in suites:\n",
    "    RunUpdate(suite)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The results are almost identical; the remaining difference is unlikely to matter in practice."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEPCAYAAABsj5JaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcZGWV5//PiYzIfa2sfaGKooACbERFQGnGpPUnm1ii\n0D9AB+U39tAqimO3L2inaavocWzHHZlBUVCRVlDRFhXp+jGYSLcOi4IiVFGFBbVSW+57ZkSc+eNG\nREZGVVZucSMiM7/v16teRNy498aTl4w88dznOecxd0dERGSqIsVugIiIzE4KICIiMi0KICIiMi0K\nICIiMi0KICIiMi0KICIiMi2hBxAzu9DMtprZNjO78Sivn2xmvzazQTP72FFej5jZ78zsgbDbKiIi\nkxdqADGzCHAbcAFwGnCVma3P2a0N+DDw2XFOcwPwfGiNFBGRaQm7B3IWsN3dd7r7CHAvsCF7B3c/\n7O6/BeK5B5vZSuBi4Bsht1NERKYo7ACyAtid9XxPattkfRH4OKB0eRGRElOyg+hmdglwwN2fASz1\nT0RESkQ05PPvBY7Ler4ytW0yzgXebmYXA1VAnZnd7e7X5O5oZuqhiIhMkbvP6It52D2QJ4F1Zrba\nzMqBK4FjzabK/DDu/gl3P87d16aOe+RowSNrf/1z55Of/GTR21AK/3QddC10LY79Lx9C7YG4e8LM\nrgc2EwSrO919i5ldF7zsd5jZEuApoA5ImtkNwKnu3htm20REZGbCvoWFuz8EnJyz7WtZjw8AqyY4\nx6PAo6E0UEREpqVkB9FlelpaWordhJKg6zBK12KUrkV+Wb7uhRWTmflc+DlERArFzPAZDqKHfgtL\nRORo1qxZw86dO4vdjDlv9erVvPzyy6GcWz0QESmK1DfgYjdjzhvvOuejB6IxEBERmRYFEBERmRYF\nEBERmRYFEBGRadi9ezf19fUFGceJRCLs2LEj9PeZKgUQEZGjOP7443nkkUfGfX3VqlV0d3djFn6d\n10K8x3QogIiITFEikSjo+5XqbDUFEBGRHNdccw27du3ibW97G/X19Xz2s58lEolw1113sXr1at78\n5jezc+dOIpEIyWQSgG9961uceuqp1NfXs27dOu64447M+R599FFWrVrFF77wBZYsWcKKFSv41re+\nlXm9vb2dSy+9lIaGBs4++2xuvvlmzjvvvKO2bXh4mL/9279l9erVLFu2jA9+8IMMDQ2Fej3Go0RC\nESlJ77rhq3k93/1f/utJ73v33Xfz2GOPcdddd3H++eezc+dObrzxRn71q1+xdetWIpEI+/fvH3Nr\nacmSJTz44IOsWbOGxx57jAsvvJCzzjqLM844A4D9+/fT09PDvn372Lx5M5dffjmXXXYZDQ0NfPCD\nH6Suro6DBw+yY8cOLrjgAtasWXPUtt1444289NJL/OEPfyAajXL11Vdzyy238KlPfWpG12c61AMR\nERlH9q0jM2PTpk1UVVVRUVFxxL4XXXRR5o/+eeedx1vf+lYee+yxzOvl5eXcfPPNlJWVcdFFF1Fb\nW8sLL7xAMpnkRz/6EbfccgsVFRWccsopvPe97x23TV//+tf54he/SENDAzU1Ndx0001873vfy98P\nPQXqgYiITNLKlSvHfe0Xv/gFt9xyC9u2bSOZTDIwMMDpp5+eeb25uZlIZPQ7e3V1Nb29vRw6dIhE\nIjHm3KtWHb1A+aFDh+jv7+d1r3tdZlsymSzaGIkCiMgssO9wN//5K79kaCTBl687j1NX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l9B9g/D6/FHmC3uz+Ven4/QUCZj78XbwF2uHu7uyeA\nHwNvZH5ei7Txfva9wKqs/Sb193Q2B5BMkqKZlRMkGj5Q5DYV2l3A8+7+5axtDwDvSz1+L/CT3IPm\nGnf/hLsf5+5rCX4PHnH3/wj8lPl3LQ4Au83spNSmNwPPMQ9/LwhuXZ1jZpWpAeE3E0yymE/Xwhjb\nKx/vZ38AuDI1S+14YB3wxIQnn815IGZ2IcGMk3Si4T8VuUkFY2bnAr8CniXohjrwCYL/6d8n+Dax\nE/hLd+8sVjsLzczeBPyNu7/dzBYwD6+Fmb2aYDJBDNhBkJxbxvy8Fp8k+FIxAjwNvB+oYx5cCzP7\nLtACNAMHgE8C/wL8gKP87Gb2d8B/IrhWN7j75gnfYzYHEBERKZ7ZfAtLRESKSAFERESmRQFERESm\nRQFERESmRQFERESmRQFERESmRQFERESmRQFERESmRQFEJM/M7Ewz+32qLERNakGjU4vdLpF8Uya6\nSAjM7BaC9SeqCIobfqbITRLJOwUQkRCYWYyg4OcA8EbXB03mIN3CEgnHQqCWoHBfZZHbIhIK9UBE\nQmBmPyFYm+R4YLm7f7jITRLJu2ixGyAy15jZfwSG3f1eM4sA/25mLe7eWuSmieSVeiAiIjItGgMR\nEZFpUQAREZFpUQAREZFpUQAREZFpUQAREZFpUQAREZFpUQAREZFpUQAREZFp+b+ev4lSMiR+4AAA\nAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fe6ec37f090>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "thinkplot.Pdfs(suites)\n",
    "thinkplot.Config(xlabel='x', ylabel='Probability')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The binomial likelihood function\n",
    "\n",
    "We can make the Euro class more efficient by computing the likelihood of the entire dataset at once, rather than one coin toss at a time.\n",
    "\n",
    "If the probability of heads is p, we can compute the probability of k=140 heads in n=250 tosses using the binomial PMF."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class Euro2(thinkbayes2.Suite):\n",
    "    \"\"\"Represents hypotheses about the probability of heads.\"\"\"\n",
    "\n",
    "    def Likelihood(self, data, hypo):\n",
    "        \"\"\"Computes the likelihood of the data under the hypothesis.\n",
    "\n",
    "        hypo: integer value of x, the probability of heads (0-100)\n",
    "        data: tuple of (number of heads, number of tails)\n",
    "        \"\"\"\n",
    "        x = hypo / 100.0\n",
    "        heads, tails = data\n",
    "        like = x**heads * (1-x)**tails\n",
    "        return like"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I left out the binomial coefficient ${n}\\choose{k}$ because it does not depend on `p`, so it's the same for all hypotheses.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.6088321798736822e-76"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "suite = Euro2(xrange(0, 101))\n",
    "dataset = 140, 110\n",
    "suite.Update(dataset)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's what the posterior looks like."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEACAYAAABVtcpZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtwXOd93vHvgwuvAAheJMoiRepCibJYR4ovMm3HNWyl\nlizPmJ20zUjJVKmbTDkZ01bjNpXjf0zOdJK0mdSxR+1YbGQ3cuPStuLWbEZWFEeBYkexrBtrmaIi\nUoopihLBGy4ESJAA+Osfu1icXeGy2D27Z8F9PjMan3P2PYsXx8Q++77ved+jiMDMzJpTS9YVMDOz\n7DgEzMyam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8l1juyUtowmvRUS8Afwh8Bq5D//B\niPg+TXgtEi6f4Xcv/Tw9Shmfp1mHgAGSOoCHgXvzLYLS0fpLfvRe0seBvnzLaLYm7CV/Lch1ebwT\n+K8R8U5yd9x9jub8d9FN7pvvRuBKci2CX6UJr8Usqvrdsw6Bo8CGxP76/LGmkW/iPgx8PSK+mz/c\nl197CUlXAMezql8dfQD4hKRXgf8FfETS14FjTXgtXgeORMQz+f0/IxcKzfjv4heBVyPidERMAP8b\neD/NeS14XTmCAAABM0lEQVQmzfS7HwWuSpQr6/M06xAoTESTtIjcZLK9Gdep3r4KvBgRX0oc2wv8\nq/z2rwHfLT3pUhMRn4+IDRFxLbl/B49HxL8E/i/Ndy36gCOSJh94fBuwnyb8d0GuG2irpCX5Qc7b\nyN040EzXQhS3jmf63fcCd+XvnroG2AT8eM43z3qegKQ7yN0JMTmZ7PczrVAdSfoA8DfAC+SadAF8\nntz/cd8il+qHgV+OiIGs6llvkj4E/LuI+ISkVTThtZB0M7kB8nbgVXITMFtpzmvxBXJfDMaA54Hf\nADppgmsh6RtAD7Aa6AO+APwf4NtM87tL+h3g18ldq3sj4rE5f0bWIWBmZtnJujvIzMwy5BAwM2ti\nDgEzsybmEDAza2IOATOzJuYQMDNrYg4BM7Mm5hAwM2ti/x9xO57grWDypQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fe6ec254f90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "thinkplot.Pdf(suite)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Beta distribution\n",
    "\n",
    "The Beta distribution is a conjugate prior for the binomial likelihood function, which means that if you start with a Beta distribution and update with a binomial likelihood, the posterior is also Beta.\n",
    "\n",
    "Also, given the parameters of the prior and the data, we can compute the parameters of the posterior directly.  The following class represents a Beta distribution and provides a constant-time Update method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from scipy import special\n",
    "\n",
    "class Beta:\n",
    "    \"\"\"Represents a Beta distribution.\n",
    "\n",
    "    See http://en.wikipedia.org/wiki/Beta_distribution\n",
    "    \"\"\"\n",
    "    def __init__(self, alpha=1, beta=1, label=None):\n",
    "        \"\"\"Initializes a Beta distribution.\"\"\"\n",
    "        self.alpha = alpha\n",
    "        self.beta = beta\n",
    "        self.label = label if label is not None else '_nolegend_'\n",
    "\n",
    "    def Update(self, data):\n",
    "        \"\"\"Updates a Beta distribution.\n",
    "\n",
    "        data: pair of int (heads, tails)\n",
    "        \"\"\"\n",
    "        heads, tails = data\n",
    "        self.alpha += heads\n",
    "        self.beta += tails\n",
    "\n",
    "    def Mean(self):\n",
    "        \"\"\"Computes the mean of this distribution.\"\"\"\n",
    "        return self.alpha / (self.alpha + self.beta)\n",
    "\n",
    "    def MAP(self):\n",
    "        \"\"\"Computes the value with maximum a posteori probability.\"\"\"\n",
    "        a = self.alpha - 1\n",
    "        b = self.beta - 1\n",
    "        return a / (a + b)\n",
    "\n",
    "    def Random(self):\n",
    "        \"\"\"Generates a random variate from this distribution.\"\"\"\n",
    "        return random.betavariate(self.alpha, self.beta)\n",
    "\n",
    "    def Sample(self, n):\n",
    "        \"\"\"Generates a random sample from this distribution.\n",
    "\n",
    "        n: int sample size\n",
    "        \"\"\"\n",
    "        size = n,\n",
    "        return np.random.beta(self.alpha, self.beta, size)\n",
    "\n",
    "    def EvalPdf(self, x):\n",
    "        \"\"\"Evaluates the PDF at x.\"\"\"\n",
    "        return x ** (self.alpha - 1) * (1 - x) ** (self.beta - 1)\n",
    "\n",
    "    def MakePmf(self, steps=101, label=None):\n",
    "        \"\"\"Returns a Pmf of this distribution.\n",
    "\n",
    "        Note: Normally, we just evaluate the PDF at a sequence\n",
    "        of points and treat the probability density as a probability\n",
    "        mass.\n",
    "\n",
    "        But if alpha or beta is less than one, we have to be\n",
    "        more careful because the PDF goes to infinity at x=0\n",
    "        and x=1.  In that case we evaluate the CDF and compute\n",
    "        differences.\n",
    "\n",
    "        The result is a little funny, because the values at 0 and 1\n",
    "        are not symmetric.  Nevertheless, it is a reasonable discrete\n",
    "        model of the continuous distribution, and behaves well as\n",
    "        the number of values increases.\n",
    "        \"\"\"\n",
    "        if label is None and self.label is not None:\n",
    "            label = self.label\n",
    "\n",
    "        if self.alpha < 1 or self.beta < 1:\n",
    "            cdf = self.MakeCdf()\n",
    "            pmf = cdf.MakePmf()\n",
    "            return pmf\n",
    "\n",
    "        xs = [i / (steps - 1) for i in range(steps)]\n",
    "        probs = [self.EvalPdf(x) for x in xs]\n",
    "        pmf = Pmf(dict(zip(xs, probs)), label=label)\n",
    "        return pmf\n",
    "\n",
    "    def MakeCdf(self, steps=101):\n",
    "        \"\"\"Returns the CDF of this distribution.\"\"\"\n",
    "        xs = [i / (steps - 1) for i in range(steps)]\n",
    "        ps = special.betainc(self.alpha, self.beta, xs)\n",
    "        cdf = Cdf(xs, ps)\n",
    "        return cdf\n",
    "\n",
    "    def Percentile(self, ps):\n",
    "        \"\"\"Returns the given percentiles from this distribution.\n",
    "\n",
    "        ps: scalar, array, or list of [0-100]\n",
    "        \"\"\"\n",
    "        ps = np.asarray(ps) / 100\n",
    "        xs = special.betaincinv(self.alpha, self.beta, ps)\n",
    "        return xs\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's how we use it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5595238095238095"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "beta = Beta()\n",
    "beta.Update((140, 110))\n",
    "beta.Mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And here's the posterior."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     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/6IT\nOASszb5eXet61/Ba/Cfgy7nrAPQCLbWue0LX44PAjcDzs7xfdnam2fKvZrLYQlPyWrj7L909txjL\nL8nMmViIok4E/BzwEHA6zcqlLMq1+DTwXXc/CeDuZ1OuY1qiXAsH2rPb7UCvu0+kWMfUuPvPgP45\nipSdnWmG/2wTweYqc3KGMgtBlGsR+iNgoc5qKXktzOwK4J+7+/+kwjkk80SU/y+uA1aa2U/N7ICZ\n/UFqtUtXlGtxL3C9mb0O/Bq4K6W61aOyszOpSV4SEzP7CJnRU/NjHYJk/BUQ9vku5A+AUlqAdwEf\nBZYDvzCzX7j7sbkPW5BuAZ5z94+a2Ubgx2b2DncfqXXF5oM0w/8ksD54vS67r7jMlSXKLARRrgVm\n9g5gL7Dd3ef6yjefRbkWNwH7LLMWw2rgVjMbd/f9KdUxLVGuxWvAWXcfA8bM7B+BG8j0jy8kUa7F\nZ4AvA7j7y2b2W2AL8HQqNawvZWdnmt0++cliZraIzISv4j/e/cCdkJ9ZPODup1KsY1pKXgszWw98\nF/gDd38f9mVrAAAA1UlEQVS5BnVMS8lr4e7XZH+uJtPv/+8XYPBDtL+R7wMfNLNmM1tG5ubeQpw7\nE+VaHAc+DpDt374OeCXVWqbLmP1bb9nZmVrL36uYLLbQRLkWwH8GVgJ/nW3xjrv7rIvizVcRr0XB\nIalXMiUR/0ZeMrMfAc8Dk8Bed3+xhtVORMT/L/4C+Ltg+OOfuXtfjaqcKDP7JtANrDKzV4EvAYuo\nIjs1yUtEpAHpMY4iIg1I4S8i0oAU/iIiDUjhLyLSgBT+IiINSOEvItKAFP4iIg1I4S8i0oD+P4mv\nfKftg/U8AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fe6ec188210>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "thinkplot.Pdf(beta.MakePmf())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Amazing, no?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise:** One way to construct priors is to make a Beta distribution and adjust the parameters until it has the shape you want.  Then when you do an update, the data get added to the parameters of the prior.  Since the parameters of the prior play the same mathematical role as the data, they are sometimes called \"precounts\".\n",
    "\n",
    "Suppose you believe that most coins are fair or unlikely to deviate from 50% by more than a few percentage points.  Construct a prior that captures this belief and update it with the Euro data.  How much effect does it have on the posterior, compared to the uniform prior?\n",
    "\n",
    "Hint: A Beta distribution with parameters `(1, 1)` is uniform from 0 to 1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "**Exercise:**  At the 2016 Summer Olympics in the Women's Skeet event, Kim Rhode faced Wei Meng in the bronze medal match.  They each hit 15 of 25 skeets, sending the match into sudden death.  In the first round, both hit 1 of 2 skeets.  In the next two rounds, they each hit 2 skeets.  Finally, in the fourth round, Rhode hit 2 and Wei hit 1, so Rhode won the bronze medal, making her the first Summer Olympian to win an individual medal at six consecutive summer games.\n",
    "\n",
    "But after all that shooting, what is the probability that Rhode is actually a better shooter than Wei?  If the same match were held again, what is the probability that Rhode would win?\n",
    "\n",
    "As always, you will have to make some modeling decisions, but one approach is to estimate, for each shooter, the probability of hitting a skeet.  Then, to estimate the probability that Rhode is a better shooter, you can draw samples from the two posterior distributions and compare them.  To estimate the probability of winning a rematch, you could draw samples from the posterior distributions and simulate a round of 25 shots."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise** Suppose that instead of observing coin tosses directly, you measure the outcome using an instrument that is not always correct. Specifically, suppose there is a probability `y` that an actual heads is reported as tails, or actual tails reported as heads.\n",
    "\n",
    "Write a class that estimates the bias of a coin given a series of outcomes and the value of `y`.\n",
    "\n",
    "How does the spread of the posterior distribution depend on `y`?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise** This exercise is inspired by a question posted by a “redditor” named dominosci on Reddit’s statistics “subreddit” at http://reddit.com/r/statistics.\n",
    "\n",
    "Reddit is an online forum with many interest groups called subreddits. Users, called redditors, post links to online content and other web pages. Other redditors vote on the links, giving an “upvote” to high-quality links and a “downvote” to links that are bad or irrelevant.\n",
    "\n",
    "A problem, identified by dominosci, is that some redditors are more reliable than others, and Reddit does not take this into account.\n",
    "\n",
    "The challenge is to devise a system so that when a redditor casts a vote, the estimated quality of the link is updated in accordance with the reliability of the redditor, and the estimated reliability of the redditor is updated in accordance with the quality of the link.\n",
    "\n",
    "One approach is to model the quality of the link as the probability of garnering an upvote, and to model the reliability of the redditor as the probability of correctly giving an upvote to a high-quality item.\n",
    "\n",
    "Write class definitions for redditors and links and an update function that updates both objects whenever a redditor casts a vote."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Solution goes here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
